<!DOCTYPE html>
<html lang="zh-cn">
<head>
  <title>Noderce 管理中心</title>
  <link rel="stylesheet" href="/admin/assets/style.css">
  <script src="/libs/jquery.min.js"></script>
  <script src="/libs/cal.js"></script>
  <script src="/libs/pagedown/Markdown.Converter.js"></script>
  <script src="/libs/pagedown/Markdown.Sanitizer.js"></script>
  <script src="/libs/pagedown/Markdown.Editor.js"></script>
</head>
<body>
<div id="wrapper">
  <div id="nav">
    <ul>
      <li><a href="/admin">Home</a><span> ›</span></li>
      <li><a href="/admin/post">Post Index</a><span> ›</span></li>
      <li><a href="/admin/post/edit/<%=post.slug%>"><%=post.title%></a><span> ›</span></li>
    </ul>
    <div class="quick"><a href="/admin/post/write" title="Write Post"><span>Write</span></a></div>
  </div>
  <form id='write_post' method='post'>
    <div id='post_info'>
      <div class='item title'>
        <label for='post_title'><span>Title</span></label>
        <input type='text' name='title' id='post_title' value='<%=post.title%>' required="" placeholder="标题"/>
      </div>
      <div class='item slug'>
        <label for='post_slug'><span>Slug</span></label>
        <input type='text' name='slug' id='post_slug' value='<%=post.slug%>' required="" placeholder="别名"/>
      </div>
      <div class='item created'>
        <label for='post_created'><span>Created</span></label>
        <input type='text' name='created' id='post_created' value='<%=post.created%>' required=''/>
      </div>
      <div class='item tags'>
        <label for='post_tags'><span>Tags</span></label>
        <%if(post.tags != undefined){%>
        <input type='text' name='tags' id='post_tags' value='<%=post.tags%>' required='' placeholder="标签">
        <%}else{%>
        <input type='text' name='tags' id='post_tags' required='' placeholder="标签，在英文逗号分割">
        <%}%>
      </div>
      <div class="clearfix"></div>
    </div>
    <div id='content'>
      <div class="wmd-panel">
        <div id="wmd-button-bar"></div>
        <textarea class="wmd-input post_content" name='content' id="wmd-input" required=''><%=post.content%></textarea>
      </div>
    </div>
    <div id='meta'>
      <input type='hidden' name='old_slug' id="post_old_slug" value='<%=post.slug%>'>
      <button class='btn btn-small'><a id='post-it'>Edit Done</a></button>
    </div>
    <div class="clearfix"></div>
    <div id="preview">
      <div id="wmd-preview" class="wmd-panel wmd-preview"></div>
    </div>
  </form>
</div>
</body>
<script>
  $('input#post_created').simpleDatepicker({ startdate: 2009, enddate: 2013 });
  (function () {
    var converter = Markdown.getSanitizingConverter();
    var editor = new Markdown.Editor(converter);
    editor.run();

    window.onbeforeunload = function(){
      return '你正在编辑日志，确定不保存编辑内容吗？';
    };

    $("#post-it").click(function(){
      window.onbeforeunload = null;
    });

  })();
</script>